package com.thxy.jxgl.mubiaoka.servlet;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.thxy.jxgl.filter.ToCh;
import com.thxy.jxgl.javaBean.khxm;
import com.thxy.jxgl.javaBean.khzb;
import com.thxy.jxgl.mubiaoka.manager.JsffManager;
import com.thxy.jxgl.mubiaoka.manager.MubiaokaManager;
import com.thxy.jxgl.mubiaoka.manager.ZhibiaoManager;

/**
 * Servlet implementation class ZhibiaoServlet
 */
public class ZhibiaoServlet extends HttpServlet {
	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		String method = request.getParameter("method") == null?"":request.getParameter("method");
		request.setCharacterEncoding("gbk");
        if("addzhibiao".equals(method))
        {
            khzb zb=(khzb)request.getSession().getAttribute("zhibiao");
            request.getSession().removeAttribute("zhibiao");
            String zbname=ToCh.toChinese(zb.getZb_name());
            String zbno=zb.getZb_id();
            String zbtype=zb.getZb_type();
            boolean ins=ZhibiaoManager.getInstance().addZhibiao(zb);
        	//boolean ins=MubiaokaManager.getInstance().addXm(xmno, xmname);
        }else if ("delezhibiao".equals(method)) {
			String zbno=request.getParameter("zbno");
			ZhibiaoManager.getInstance().deleZhibiao(zbno);}
		else if ("editzhibiao".equals(method)) {
			String zbno=request.getParameter("zbno");
			String zbname=request.getParameter("zb_name");
			String zbtype=request.getParameter("zb_type");
			boolean upd=ZhibiaoManager.getInstance().updateZhibiao(zbname, zbtype,zbno);
		}
       
		List zbList=new ArrayList();
		zbList=ZhibiaoManager.getInstance().getZhibiao();
		request.getSession().setAttribute("zbList", zbList);
		request.getRequestDispatcher("/mbkgl/zhibiao.jsp").forward(request, response);

		}
	
}
